TYRO.IClientWithUI Class
Overview
The Tyro IClient with UI provides a simpler path for a POS to integrate with a Tyro terminal. The regular IClient allows a POS to have full control over presentation of status messages and questions but requires a POS vendor to write more code. The IClient with UI allows a POS to start a transaction and just wait for the transaction result. See the sequence diagrams in the TYRO module description.To use the Tyro iClient a POS needs to include the following library:
<script src="https://iclient.tyro.com/iclient-with-ui-v1.js" type="text/javascript"></script>
Replace iclient.tyro.com with one of the following URLs for development/testing:
- iclienttest.tyro.com connects to the integration server simulator which does not require a physical payment terminal
- iclientpreprod.tyro.com connects a test system that can only be used with a physical terminal
Configuration
Configuration for the Tyro iClient can be found at:https://iclient.tyro.com/configuration.html
A merchant can use this page to:
- pair their terminal with their browser
- test their terminal connection
Replace iclient.tyro.com with one of the following URLs for development/testing:
- iclientsimulator.test.tyro.com connects to the integration server simulator which does not require a physical payment terminal
- iclient.test.tyro.com connects a test system that can only be used with a physical terminal
For pairing a POS and terminal, the Tyro configuration page can be used. The alternative URLs above should be used for the test and pre production environments.
A working example of using the iclient library to make a purchase can be found here.
Constructor
TYRO.IClientWithUI
-
apiKey -
posProductData
Parameters:
-
apiKeyStringThe API key provided by Tyro.
-
posProductDataObjectAn object containing the following properties (check with Tyro in case of any questions):
-
posProductVendorStringName of your company.
-
posProductNameStringName of your product.
-
posProductVersionStringVersion of your product.
-
Example:
var iclient = new TYRO.IClientWithUI("apiKey", {posProductVendor: "Name of your company", posProductName: "Name of your product", posProductVersion: "Version of your product"});
Item Index
Methods
- addTip
- cancelHealthPointClaim
- closeTab
- completePreAuth
- continueLastTransaction
- healthpointReconciliationReport
- initiateBulkBillEasyclaim
- initiateFullyPaidEasyclaim
- initiateHealthPointClaim
- initiateIncrementPreAuth
- initiateOpenPreAuth
- initiateOpenTab
- initiatePartPaidEasyclaim
- initiatePurchase
- initiateRefund
- manualSettlement
- pairTerminal
- reconciliationReport
- voidPreAuth
- voidTab
Methods
addTip
-
completionReference -
tipAmount -
responseReceivedCallback
Add a tip to a previous purchase (initiatePurchase).
Parameters:
-
completionReferenceStringTransaction identifier from the original transaction.
-
tipAmountStringThe tip amount to add in cents.
-
responseReceivedCallbackFunctionInvoked to indicate success or failure. Called with a single Object containing the following properties:
resultString
One of the following values: success, failure.messageString
Message to show the merchant.
Example:
// to add a $3.00 tip to a transaction with completion reference 543123
iclient.addTip("543123", "300", yourPosCode.handleResponse);
cancelHealthPointClaim
-
requestParams -
transactionCallbacks
Tell the terminal to cancel a completed HealthPoint claim.
Parameters:
-
requestParamsObjectAn object containing the following properties:
-
providerIdStringThe 8 character id of the provider attending the patient.
-
serviceTypeStringThe 1 alphabetic character representing the category of service.
-
claimItemsCountStringThe total number of claim items.
-
totalClaimAmountIntThe total amount of all claim items in cents.
-
claimItemsStringA list of claim items as a JSON array.
-
refTagStringThe reference tag returned in the original claim's final transaction status response.
-
[mid]Int optionalOverride the configured mid for multi-merchant terminals or if your browser does not support local storage.
-
[tid]Int optionalOverride the configured tid for multi-merchant terminals or if your browser does not support local storage.
-
[integrationKey]String optionalSupply the integration key if your browser does not support local storage.
-
-
transactionCallbacksObject-
transactionCompleteCallbackFunction
-
Example:
// to initiate a cancel of a completed healthpoint claim with two claim items totaling $250
iclient.cancelHealthPointClaim({providerId: "2147661H", serviceType: "D", claimItemsCount: "2", totalClaimAmount: "25000", refTag: "0960001", claimItems: [
{
"claimAmount": "10000",
"serviceCode": "00001",
"description": "SKULL XRAY",
"serviceReference": "01",
"patientId": "02",
"serviceDate": "20131010"
},
{
"claimAmount": "15000",
"serviceCode": "00001",
"description": "SKULL XRAY",
"serviceReference": "01",
"patientId": "02",
"serviceDate": "20140508"
}
]}, {
transactionCompleteCallback: yourPosCode.handleComplete
});
closeTab
-
completionReference -
amount -
responseReceivedCallback
Close a previously opened bar tab (initiateOpenTab) with a final amount. The customer will be charged.
Parameters:
-
completionReferenceStringTransaction identifier from the original transaction.
-
amountStringThe final amount to charge the customer.
-
responseReceivedCallbackFunctionInvoked to indicate success or failure. Called with a single Object containing the following properties:
resultString
One of the following values: success, failure.messageString
Message to show the merchant.
Example:
// to close the tab with completion reference 543123 and bill a customer $120.01
iclient.closeTab("543123", "12001", yourPosCode.handleResponse);
completePreAuth
-
requestParams -
responseReceivedCallback
Close a previously opened preAuth (initiateOpenPreAuth) with a final amount. The customer will be charged.
Parameters:
-
requestParamsObjectAn object containing the following properties:
-
completionReferenceStringTransaction identifier from the original transaction.
-
amountStringThe final amount to charge the customer.
-
[integrationKey]String optionalSupply the integration key if your browser does not support local storage.
-
[mid]Int optionalOverride the configured mid for multi-merchant terminals.
-
[tid]Int optionalOverride the configured tid for multi-merchant terminals.
-
-
responseReceivedCallbackFunctionInvoked to indicate success or failure. Called with a single Object containing the following properties:
resultString
One of the following values: success, failure.messageString
Message to show the merchant.
Example:
// to close the preAuth with completion reference 543123 and bill a customer $120.01
iclient.completePreAuth({amount: "12001", completionReference: "543123"}, yourPosCode.handleResponse);
continueLastTransaction
-
transactionCallbacks
Tell the terminal to continue the last transaction.
Parameters:
-
transactionCallbacksObjectSee the transaction callbacks description for initiatePurchase.
Example:
// comtinueLastTransaction
iclient.continueLastTransactioon({
questionCallback: yourPosCode.handleQuestionChanged,
statusMessageCallback: yourPosCode.handleStatusMessageChanged,
receiptCallback: yourPosCode.handleReceiptChanged,
transactionCompleteCallback: yourPosCode.handleTransactionCompleted
});
healthpointReconciliationReport
-
requestParams -
responseReceivedCallback
Retrieve a payments or claims HealthPoint reconciliation report.
Parameters:
-
requestParamsObjectAn object containing the following properties:
-
reconDateStringThe reporting date in format yyyyMMdd.
-
reportTypeStringThe report type. Valid values are payments and claims.
-
integrationKeyStringSupply the integration key if your browser does not support local storage.
-
-
responseReceivedCallbackFunctionCallback to return the report or error message. Called with a single Object containing the following properties:
resultString
One of the following values: success, failure.dataString
The report in xml format.errorString
An error message to show the merchant. Only present when result is failure.
Example:
// to retrieve the HealthPoint payments report for 25th December 2012
iclient.healthpointReconciliationReport({
reportType: "payments",
reconDate "20121225"
}, yourPosCode.handleResponse);
initiateBulkBillEasyclaim
-
requestParams -
transactionCallbacks
Tell the terminal to start a bulk billed Easyclaim request.
Parameters:
-
requestParamsObjectAn object containing the following properties:
-
payloadStringThe Easyclaim payload that is forwarded to Medicare.
-
rightsAssignedBooleanWhether rights have already been assigned
-
[mid]Int optionalOverride the configured mid for multi-merchant terminals or if your browser does not support local storage.
-
[tid]Int optionalOverride the configured tid for multi-merchant terminals or if your browser does not support local storage.
-
[integrationKey]String optionalSupply the integration key if your browser does not support local storage.
-
-
transactionCallbacksObject-
transactionCompleteCallbackFunction
-
Example:
iclient.initiateBulkBillEasyclaim({payload: "<ns1:patienteClaimingRequest>...</ns1:patienteClaimingRequest>", rightsAssigned: true}, {
transactionCompleteCallback: yourPosCode.handleComplete
});
initiateFullyPaidEasyclaim
-
requestParams -
transactionCallbacks
Tell the terminal to start a fully paid Easyclaim request.
Parameters:
-
requestParamsObjectAn object containing the following properties:
-
payloadStringThe Easyclaim payload that is forwarded to Medicare.
-
[mid]Int optionalOverride the configured mid for multi-merchant terminals or if your browser does not support local storage.
-
[tid]Int optionalOverride the configured tid for multi-merchant terminals or if your browser does not support local storage.
-
[integrationKey]String optionalSupply the integration key if your browser does not support local storage.
-
-
transactionCallbacksObject-
transactionCompleteCallbackFunction
-
Example:
iclient.initiateFullyPaidEasyclaim({payload: "<ns1:patienteClaimingRequest>...</ns1:patienteClaimingRequest>"}, {
transactionCompleteCallback: yourPosCode.handleComplete
});
initiateHealthPointClaim
-
requestParams -
transactionCallbacks
Tell the terminal to start a HealthPoint claim.
Parameters:
-
requestParamsObjectAn object containing the following properties:
-
providerIdStringThe 8 character id of the provider attending the patient.
-
serviceTypeStringThe 1 alphabetic character representing the category of service.
-
claimItemsCountStringThe total number of claim items.
-
totalClaimAmountIntThe total amount of all claim items in cents.
-
claimItemsStringA list of claim items as a JSON array.
-
[mid]Int optionalOverride the configured mid for multi-merchant terminals or if your browser does not support local storage.
-
[tid]Int optionalOverride the configured tid for multi-merchant terminals or if your browser does not support local storage.
-
[integrationKey]String optionalSupply the integration key if your browser does not support local storage.
-
-
transactionCallbacksObject-
transactionCompleteCallbackFunction
-
Example:
// to initiate a dental claim with two claim items totaling $250
iclient.initiateHealthPointClaim({providerId: "2147661H", serviceType: "D", claimItemsCount: "2", totalClaimAmount: "25000", claimItems: [
{
"claimAmount": "10000",
"serviceCode": "00001",
"description": "SKULL XRAY",
"serviceReference": "01",
"patientId": "02",
"serviceDate": "20131010"
},
{
"claimAmount": "15000",
"serviceCode": "00001",
"description": "SKULL XRAY",
"serviceReference": "01",
"patientId": "02",
"serviceDate": "20140508"
}
]}, {
transactionCompleteCallback: yourPosCode.handleComplete
});
initiateIncrementPreAuth
-
requestParams -
responseReceivedCallback
Send incremental pre-auth to increase the amount of previously opened pre-auth (initiateOpenPreAuth) with an incremental amount.
Parameters:
-
requestParamsObjectAn object containing the following properties:
-
completionReferenceStringTransaction identifier from the original transaction.
-
amountStringThe incremental amount to increment the pre-auth amount.
-
[integrationKey]String optionalSupply the integration key if your browser does not support local storage.
-
[mid]Int optionalOverride the configured mid for multi-merchant setup if your browser does not support local storage.
-
[tid]Int optionalOverride the configured tid for multi-merchant setup if your browser does not support local storage.
-
[transactionId]String optionalSupply a transaction Id to be used for the transaction.
-
-
responseReceivedCallbackFunctionSee the transaction callbacks description for initiateIncrementPreAuth.
Example:
// to increment the preAuth by $50.00 with completion reference 543123.
iclient.initiateIncrementPreAuth({amount: "5000", completionReference: "543123"}, yourPosCode.handleResponse);
initiateOpenPreAuth
-
requestParams -
transactionCallbacks
Tell the terminal to start an open preAuth transaction.
Parameters:
-
requestParamsObjectAn object containing the following properties:
-
amountStringThe preAuth limit (maximum amount to charge the customer) in cents.
-
integratedReceiptBooleanindicate whether receipts will be printed on the POS (true) or on the terminal (false).
-
[mid]Int optionalOverride the configured mid for multi-merchant terminals or if your browser does not support local storage.
-
[tid]Int optionalOverride the configured tid for multi-merchant terminals or if your browser does not support local storage.
-
[integrationKey]String optionalSupply the integration key if your browser does not support local storage.
-
[transactionId]String optionalSupply a transaction Id to be used for the transaction.
-
-
transactionCallbacksObjectSee the transaction callbacks description for initiatePurchase.
Example:
// open preAuth for $10.00
iclient.initiateOpenPreAuth({amount: "1000", integratedReceipt: false}, {
receiptCallback: yourPosCode.handleReceipt,
transactionCompleteCallback: yourPosCode.handleComplete
});
initiateOpenTab
-
requestParams -
transactionCallbacks
Tell the terminal to start an open tab transaction.
Parameters:
-
requestParamsObjectAn object containing the following properties:
-
amountStringThe tab limit (maximum amount to charge the customer) in cents.
-
integratedReceiptBooleanindicate whether receipts will be printed on the POS (true) or on the terminal (false).
-
[mid]Int optionalOverride the configured mid for multi-merchant terminals or if your browser does not support local storage.
-
[tid]Int optionalOverride the configured tid for multi-merchant terminals or if your browser does not support local storage.
-
[integrationKey]String optionalSupply the integration key if your browser does not support local storage.
-
[transactionId]String optionalSupply a transaction Id to be used for the transaction.
-
-
transactionCallbacksObjectSee the transaction callbacks description for initiatePurchase.
Example:
// open tab for $10.00
iclient.initiateOpenTab({amount: "1000", integratedReceipt: false}, {
receiptCallback: yourPosCode.handleReceipt,
transactionCompleteCallback: yourPosCode.handleComplete
});
initiatePartPaidEasyclaim
-
requestParams -
transactionCallbacks
Tell the terminal to start a part paid Easyclaim request.
Parameters:
-
requestParamsObjectAn object containing the following properties:
-
payloadStringThe Easyclaim payload that is forwarded to Medicare.
-
[mid]Int optionalOverride the configured mid for multi-merchant terminals or if your browser does not support local storage.
-
[tid]Int optionalOverride the configured tid for multi-merchant terminals or if your browser does not support local storage.
-
[integrationKey]String optionalSupply the integration key if your browser does not support local storage.
-
-
transactionCallbacksObject-
transactionCompleteCallbackFunction
-
Example:
iclient.initiatePartPaidEasyclaim({payload: "<ns1:patienteClaimingRequest>...</ns1:patienteClaimingRequest>"}, {
transactionCompleteCallback: yourPosCode.handleComplete
});
initiatePurchase
-
requestParams -
transactionCallbacks
Tell the terminal to start a purchase transaction.
Parameters:
-
requestParamsObjectAn object containing the following properties:
-
amountStringThe purchase amount (amount to charge the customer) in cents.
-
[cashout]String optionalCash out amount in cents.
-
integratedReceiptBooleanindicate whether receipts will be printed on the POS (true) or on the terminal (false).
-
integratedReceiptWidthStringThe width of the integrated receipt in number of characters as a String.
-
[mid]Int optionalOverride the configured mid for multi-merchant terminals or if your browser does not support local storage.
-
[tid]Int optionalOverride the configured tid for multi-merchant terminals or if your browser does not support local storage.
-
[integrationKey]String optionalSupply the integration key if your browser does not support local storage.
-
[transactionId]String optionalSupply a transaction Id to be used for the transaction.
-
[healthpointTransactionId]String optionalThe integrated transaction ID of the original HealthPoint Claim (used for gap payments).
-
[enableSurcharge]Boolean optionalApply a surcharge to this transaction (if the card used attracts a surcharge).
-
[requestCardToken]Boolean optionalRequest a token representing the card used for the current purchase.
-
-
transactionCallbacksObject-
[receiptCallback]Function optionalSee receipt callback.
-
transactionCompleteCallbackFunction
-
Example:
// purchase for $10.00
iclient.initiatePurchase({amount: "1000", integratedReceipt: false}, {
receiptCallback: yourPosCode.handleReceipt,
transactionCompleteCallback: yourPosCode.handleComplete
});
initiateRefund
-
requestParams -
transactionCallbacks
Tell the terminal to start a refund transaction.
Parameters:
-
requestParamsObjectAn object containing the following properties:
-
amountStringThe refund amount (amount to be given to the customer) in cents.
-
integratedReceiptBooleanindicate whether receipts will be printed on the POS (true) or on the terminal (false).
-
integratedReceiptWidthStringThe width of the integrated receipt in number of characters as a String.
-
[mid]Int optionalOverride the configured mid for multi-merchant terminals or if your browser does not support local storage.
-
[tid]Int optionalOverride the configured tid for multi-merchant terminals or if your browser does not support local storage.
-
[integrationKey]String optionalSupply the integration key if your browser does not support local storage.
-
[transactionId]String optionalSupply a transaction Id to be used for the transaction.
-
-
transactionCallbacksObjectSee the transaction callbacks description for initiatePurchase.
Example:
// refund for $10.00
iclient.initiateRefund({amount: "1000", integratedReceipt: false}, {
receiptCallback: yourPosCode.handleReceipt,
transactionCompleteCallback: yourPosCode.handleComplete
});
manualSettlement
-
responseReceivedCallback -
options
Manually settle the terminal: close off reporting for the day.
Parameters:
-
responseReceivedCallbackFunctionCalled with a single Object containing the following properties:
resultString
One of the following values: success, failure.messageString
Message to show the merchant.currentTerminalBusinessDayString
Current reporting day after settlement request. Only returned if result is success. Format dd/MM/yyyy.
-
optionsObjectAn object containing the following properties:
-
[mid]Int optionalOverride the configured mid for multi-merchant terminals or if your browser does not support local storage.
-
[tid]Int optionalOverride the configured tid for multi-merchant terminals or if your browser does not support local storage.
-
[integrationKey]String optionalSupply the integration key if your browser does not support local storage.
-
Example:
// to close the current reporting day
iclient.manualSettlement(yourPosCode.handleResponse);
pairTerminal
-
mid -
tid -
responseReceivedCallback
Perform the POS side of pairing (shared secret exchange) with a terminal.
Parameters:
-
midStringTyro Merchant ID (MID)
-
tidStringTyro Terminal ID (TID)
-
responseReceivedCallbackFunctionCallback invoked to indicate status of pairing. Called with the following parameters:
responseObject
An object consisting of:statusString
One of the following values: inProgress, success, failure.
If inProgress more responses will follow.messageString
Text to show the merchant.integrationKeyString
Integration key to be used when transacting.
Example:
// to perform the POS side of pairing for the terminal identified by (MID 2, TID 1)
iclient.pairTerminal("2", "1", yourPosCode.handleResponse);
reconciliationReport
-
requestParams -
responseReceivedCallback
Retrieve a summary or detail reconciliation report.
Parameters:
-
requestParamsObjectAn object containing the following properties:
-
terminalBusinessDayStringThe reporting date in format yyyyMMdd.
-
typeStringThe report type. Valid values are summary and detail.
-
formatStringThe report format. Valid values are txt and xml. The txt version is pre-formatted in a monospaced font.
-
[integrationKey]String optionalSupply the integration key if your browser does not support local storage.
-
[mid]Int optionalOverride the configured mid for multi-merchant terminals.
-
[tid]Int optionalOverride the configured tid for multi-merchant terminals.
-
-
responseReceivedCallbackFunctionCallback to return the report or error message. Called with a single Object containing the following properties:
resultString
One of the following values: success, failure.formatString
The request parameter format is passed back for convenience.typeString
The request parameter type is passed back for convenience.dataString
The report. Pre-formatted text when format is txt. Parsable xml when format xml.errorString
An error message to show the merchant. Only present when result is failure.
Example:
// to retrieve the pre-formatted detail report for 25th December 2012
iclient.reconciliationReport({
type: "detail",
terminalBusinessDay "20121225"
format: "txt"
}, yourPosCode.handleResponse);
voidPreAuth
-
requestParams -
responseReceivedCallback
Void a previously opened preAuth (initiateOpenPreAuth). This discards the hold on funds in the customer's account.
Parameters:
-
requestParamsObjectAn object containing the following properties:
-
completionReferenceStringTransaction identifier from the original transaction.
-
[integrationKey]String optionalSupply the integration key if your browser does not support local storage.
-
[mid]Int optionalOverride the configured mid for multi-merchant terminals.
-
[tid]Int optionalOverride the configured tid for multi-merchant terminals.
-
-
responseReceivedCallbackFunctionInvoked to indicate success or failure. Called with a single Object containing the following properties:
resultString
One of the following values: success, failure.messageString
Message to show the merchant.
Example:
// to void a preAuth with completion reference 543123
iclient.voidPreAuth({completionReference: "543123"}, yourPosCode.handleResponse);
voidTab
-
completionReference -
responseReceivedCallback
Void a previously opened bar tab (initiateOpenTab). This discards the hold on funds in the customer's account.
Parameters:
-
completionReferenceStringTransaction identifier from the original transaction.
-
responseReceivedCallbackFunctionInvoked to indicate success or failure. Called with a single Object containing the following properties:
resultString
One of the following values: success, failure.messageString
Message to show the merchant.
Example:
// to void a bar tab with completion reference 543123
iclient.voidTab("543123", yourPosCode.handleResponse);
